<!DOCTYPE html>
<html>

<body>

<!--CONTENT SECTION START-->

<div id="main-wrapper-sec">

<section>

	<!--INNER MAIN TITLE SECTION START-->

    <h2 class="inner-main-title pr-title">login</h2>
    
    <!--INNER MAIN TITLE SECTION END-->
    
    <!--CONTENT MAIN SECTION START-->
    
  <div class="content-main-sec">
  
  <!--INNER CONTENT LEFT MENU SECTION START-->
  
  <ul class="inner-left-menu-sec">
    <?php include('cleftmenu.phtml');?>
  </ul>
  
  <!--INNER CONTENT LEFT MENU SECTION END-->
  
  <!--INNER CONTENT RIGHT SECTION START-->
  
  <article class="inner-cont-right-sec">
  
  <h1 class="inner-cont-title">Corporate Settings
  </h1>
  
  <div class="clear"></div>
  
  <!--SETTING FIELDS SECTION START onsubmit="return settingsNum()" -->
  
  <!--<aside class="set-main-sec">
	<form id="formid" method="post" onsubmit="return settingsNum1()">
		<div><?php //if(isset($data['infoGatewayMappings'][0]['remoteIps'])){ ?>
	  <input type="hidden" id="ipsValue" value="<?php// echo $data['infoGatewayMappings'][0]['remoteIps']; ?>" >
	  <?php //} ?>
	  </div>
	  <ul class="login-form-sec">
	  <li><label><b>EX:</b></label><b>10.20.15.30</b></li>
	  <li><label>IP:</label><h3 id="address"></h3> </li><li><h2 id="ipadd"><?php //if(isset($data['infoGatewayMappings'][0]['remoteIps'])){ $remoteIps=explode(",",$data['infoGatewayMappings'][0]['remoteIps']);for($i=0;$i<count($remoteIps);$i++){
	  ?> <div style="margin:-34px 0px 0px 251px;">
	  <?php //echo $remoteIps[$i];echo '<br>';?>&nbsp;&nbsp;</div><?php //}} ?><span id="pinerror" class="set_error_v"></h2><h3 id=""></h3></span></li>
		<p style="margin:0px 0px 0px -49px;"><input  type="submit" value="save"><a class="cancel" onclick="editValue()">Edit</a></p>
	  </ul>
	</form><br/><br/>
	<?php //if(isset($_GET['id'])){ if($_GET['id']==3){ ?>
	<p id="success" style="color:green;margin:-14px 0px 0px 234px;">Successfully Updated</p>
	<?php //} } ?>
  </aside>-->
  <div class="clear"></div><br/>
  <h1 style="color:red;margin:0px 0px 0px 13px;">Send Calls to IP:  176.9.51.8 </h1>
  <form  class="set-main-sec" id="formid" method="post" >
  
		<ul class="login-form-sec">
			
			<li><label><b>EX IP:</b></label><b>10.20.15.30</b></li>
		</ul>
		<div class="row" style="border-left:none !important" id="submitValue">
			<?php if(isset($data['infoGatewayMappings'][0]['remoteIps']) && $data['infoGatewayMappings'][0]['remoteIps']!=''){
				$pakageName=explode(",",$data['infoGatewayMappings'][0]['remoteIps']);
				for($i=0;$i<count($pakageName);$i++){ ?>
			<div class='span3'id='demo<?php echo $i; ?>' ><span id="spanValue<?php echo $i; ?>" ><a  href='#' value="<?php echo $pakageName[$i]; ?>" onclick="editValue('<?php echo $pakageName[$i]; ?>',<?php echo $i;?>)" >Edit</a>&nbsp;<abbr id="dataValue<?php echo $i; ?>" ><?php echo $pakageName[$i]; ?></abbr></span></div>
			<?php } } ?>
		</div>
		<div class="clear"></div> 
		<div class="set_save">
			<input  type="button" value="add new" onclick="addtextBox()">
			<input  type="button" value="save all" onclick="saveAll()">
		</div>
		<div class="clear"></div>
  </form>
  <form id="formid1" method="post" action="<?php echo $this->url('csettings', array('action' => 'csettings')); ?>">
	<input type="hidden" id="hidden" name="hidden" value="">
  </form>
  <!--SETTING FIELDS SECTION END-->
  
  </article>
  
  <!--INNER CONTENT RIGHT SECTION END-->
  
  </div>
  
  <!--CONTENT MAIN SECTION END-->
  
  <div class="clear"></div>
  
  <!--CLIENTS AREA SECTION START-->
  
  <aside class="content-main-sec ot-lg-sec"> <img src="<?php echo $this->basePath(); ?>/images/truste.jpg" alt=""> <img src="<?php echo $this->basePath(); ?>/images/secured.jpg" alt=""> <img src="<?php echo $this->basePath(); ?>/images/mcafeev.jpg" alt="">
    <h3 class="otg-title">Trusted. Safe. Reliable.</h3>
  </aside>
  
  <!--CLIENTS AREA SECTION END-->
  
  <div class="clear"></div>
  
</section>

</div>

<!--CONTENT SECTION END--> 

</body>
</html>
<script>
	var i=1;var j=0; var count='<?php echo count($pakageName);?>';
	function editValue(data,id){
		$('#spanValue'+id).hide();
		var total="'"+data+"'";
		var total1="'"+id+"'";
		$('#spanVal'+id).remove();
		$('#demo'+id).append('<span id="spanVal'+id+'"><input type="text" style="width:100px;" value='+data+' id="ip'+id+'" name="ip'+id+'"><a  href="#" value="" onclick="cancelValue('+total+','+total1+')" >Cancel</a></span>');
	}
	function cancelValue(data,id){
		$('#spanVal'+id).remove();
		$('#spanValue'+id).show();
	}
	/*function settingsNum1(){
		var num=$('#ip').val();
		$.ajax({
				type: "POST",
				url: 'corporate/csettings',
				contentType: "application/json; charset=utf-8",
				dataType: "json",
				success: function(data){
				}
		});
	}*/
	function saveAll(){
		var data = $('#formid').serializeArray();
		var finalData='';
		
		for(var j=0;j<count+1;j++){
			var textValue=$("#dataValue"+j).text();
			var ip=$("#ip"+j).val();
			if (typeof ip === "undefined") {
				finalData=finalData+textValue+',';
			}else if(ip!=''){
				finalData=finalData+ip+',';
			}else if(ip==''){
			}else{
				finalData=finalData+ip+',';
			}
		}
		finalData = finalData.replace(/\,{2,}/g, ',');
		finalData = finalData.replace(/^,|,$/g,'');
		$("#hidden").val(finalData);
		$("#formid1").submit();
	}
	function addtextBox(){
		count=parseInt(count)+1;
		finalCount=parseInt(count)+1;
		$('#submitValue').append('<div class="span3" id="demo'+count+'"><span id="spanVal'+count+'"><input type="text" style="width:100px;" value="" id="ip'+count+'" name="ip'+count+'"><a  href="javascript:void(0)" value="" onclick="removeValue('+count+')" >Cancel</a></span></div>');
	}
	function removeValue(id){
		$('#demo'+id).remove();
	}
	//location.reload(true);  refresh page
</script>













